﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AlmaDatabase;

namespace Alma.Models
{
    public class ProductReviewModel
    {
        public long ID { get; set; }
        public long ID_User { get; set; }
        public long ID_Shop { get; set; }
        public string Name_User { get; set; }
        public long ID_Product { get; set; }
        public DateTime Date { get; set; }
        public string Text { get; set; }
        public int? Score { get; set; }

        public ProductReviewModel()
        {
        }

        public ProductReviewModel(long Id)
        {
            using (var context = new AlmaDBEntities())
            {
                var rev = from reviews in context.T_Product_Reviews
                              where reviews.ID == Id
                              select reviews;
                ID = rev.First().ID;
                ID_User = rev.First().ID_User;
                ID_Product = rev.First().ID_Product;
                Date = rev.First().Date;
                Text = rev.First().Text;
                Score = rev.First().Score;
            }
        }
    }
}
